package com.phone.exception;

/**
 * Created by tisen on 2017/8/21.
 */
public class ErrorCode {
    public final static int NOT_ERROR = 0;
    public final static int UN_DEFINED_ERROR = 1;
    public final static int PARAMETER_ERROR = 2;
    public final static int NOT_EXIST_ID = 3;
    public final static int NOT_EXIST_PHONE = 4;
    public final static int NOT_EXIST_USERNAME = 5;
    public final static int NOT_EXIST_OWNER_ID = 6;
    public final static int NOT_EXIST_INVITE_ID = 7;
    public final static int NOT_EXIST_INVITEE_ID = 8;
    public final static int NOT_EXIST_WX_ID = 9;
    public final static int NOT_EXIST_QQ_ID = 10;
    public final static int USER_HAS_BEEN_INVITED = 11;
    public final static int ERROR_PHONE_OR_PASSWORD = 12;
    public final static int ERROR_USERNAME_OR_PASSWORD = 13;
    public final static int NOT_SUFFICIENT_MONEY = 14;
    public final static int EXIST_PHONE = 15;
    public final static int EXIST_USERNAME = 16;
    public final static int UN_DEFINED_ACTION = 17;
    public final static int EMPTY_PASSWORD = 18;
    public final static int EXIST_WX_ID = 19;
    public final static int EXIST_QQ_ID = 20;

    private static String[] error_messages = {"",
            "undefined error",
            "parameter error",
            "id not exist",
            "phone not exist",
            "username not exist",
            "owner id not exist",
            "invite id not exist",
            "invitee id not exist",
            "not exist wx id",
            "not exist qq id",
            "user has been invited",
            "error phone or password",
            "error username or password",
            "not sufficient money",
            "exist phone",
            "exist username",
            "undefined action",
            "empty password",
            "exist wx id",
            "exist qq id"
    };

    public static String getErrorMessage(int error_code) {
        if (error_code >= 0 && error_code <= error_messages.length) {
            return error_messages[error_code];
        } else {
            return "undefined error code";
        }
    }
}
